<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /*
        找出所有的水仙花数，三位数，各位立方和等于该数本身。
        如: 153 = 1^3 + 5^3 + 3^3
    */

   for(var i = 100; i <= 999; i++) {
       //拆分数字：个 十 百
       var ge = i % 10;
       var bai = parseInt(i / 100);
       var shi = parseInt(i % 100 / 10);

       //Math.pow(ge,3)
       var sum = Math.pow(ge,3) +  Math.pow(shi,3) +  Math.pow(bai,3);

       if(sum == i) {
           document.write('水仙花数：' + sum + '<br>')
       }
   }
</script>
</html>